﻿using System;
using UnityEngine;
using WebSocketSharp;
using WebSocketSharp.Server;

public class Laputa : WebSocketBehavior
{
    protected override void OnMessage(MessageEventArgs e)
    {
        Debug.Log($"[OnMessage]:{e.Data}");

        var msg = e.Data == "BALUS"
                  ? "Are you kidding?"
                  : "I'm not available now.";
        Send(msg);
    }

    protected override void OnOpen()
    {
        Debug.Log("[OnOpen]");
    }

    protected override void OnClose(CloseEventArgs e)
    {
        Debug.Log($"[OnClose]{e.Reason}");
    }

    protected override void OnError(ErrorEventArgs e)
    {
        Debug.Log($"[OnError]{e.Message}");
    }
}